package cn.tedu.fresheveryday.mapper;

import cn.tedu.fresheveryday.pojo.vo.ProductCategoryVO;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ProductCategoryMapper {
    /**
     * 查询全部商品类型
     * @return
     */
    @Select("select id, name, img_url, cls from product_category")
    @Result(column = "id", property = "id")
    @Result(column = "img_url", property = "imgUrl")
    @Result(
            column = "id", property = "products",
            many = @Many(select = "cn.tedu.fresheveryday.mapper.ProductMapper.selectByCid")
    )
    List<ProductCategoryVO> selectAll();
}